<template>
	<view class="user-container">
		<view class="user-top">
			<view class="header">
				<image :src="userinfo.userInfo.avatarUrl" mode=""></image>
			</view>
			<view class="name">
				{{userinfo.userInfo.nickName}}
			</view>
		</view>
		<view class="user-bottom">
			<view class="box1">
				<view>
					<text>8</text>
					<text>收藏的店铺</text>
				</view>
				<view>
					<text>8</text>
					<text>收藏的商品</text>
				</view>
				<view>
					<text>8</text>
					<text>关注的商品</text>
				</view>
				<view>
					<text>8</text>
					<text>足迹</text>
				</view>
			</view>
			<view class="box2">
				<view class="title">
					我的订单
				</view>
				<view class="box2-content">
					<view>
						<uni-icons type="wallet" size="40" color='red'></uni-icons>
						<text>待付款</text>
					</view>
					<view>
						<uni-icons type="gift" size="40" color='red'></uni-icons>
						<text>待收货</text>
					</view>
					<view>
						<uni-icons type="notification" size="40" color='red'></uni-icons>
						<text>退款/退货</text>
					</view>
					<view>
						<uni-icons type="bars" size="40" color='red'></uni-icons>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			<view class="box3">
				<view>
					<text>收货地址</text>
					<uni-icons type="forward" size="25" color='#999'></uni-icons>
				</view>
				<view>
					<text>联系客户</text>
					<uni-icons type="forward" size="25" color='#999'></uni-icons>
				</view>
				<view  @click="logout">
					<text>退出登录</text>
					<uni-icons type="forward" size="25" color='#999'></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,mapMutations
	} from 'vuex'
	export default {
		name:"my-userinfo",
		computed:{
				...mapState('userInfo', ['userinfo']),
		},
		data() {
			return {
				
			};
		},
		created() {
			console.log(222222);
			console.log(this.userinfo.userInfo);
		},
		methods:{
			...mapMutations('userInfo', ['setUserInfo','setToken','setUserAddress']),
			async logout(){
				const [err, succ] = await uni.showModal({
				    title: '提示',
				    content: '确认退出登录吗？'
				  }).catch(err => err)
				console.log(err, succ);
				  if (succ && succ.confirm) {
				    this.setUserAddress({})
				    this.setUserInfo({})
				    this.setToken('')
				  }
			}
		}
	}
</script>

<style lang="scss">
.user-container{
	.user-top{
		background-color: red;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		text-align: center;
		padding:20px 0 30px;
		.header{
			width: 200rpx;
			height: 200rpx;
			border-radius: 50%;
			border: 2px solid #fff;
			overflow: hidden;
			margin-bottom: 10px;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.name{
			color: #fff;
			font-weight: 600;
		}
	}
	.user-bottom{
		margin-top: -20px;
		padding: 0 10px;
		.box1{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			box-shadow: 0 5px 2px 0px #eee;
			border-radius: 2px;
			padding: 10px;
			margin-bottom: 10px;
			view{
				display: flex;
				flex-direction: column;
				width: 25%;
				justify-content: space-between;
				align-items: center;
				font-size: 12px;
				color: #999;
			}
		}
		.box2{
			background-color: #fff;
			box-shadow: 0 5px 2px 0px #eee;
			border-radius: 2px;
			padding: 10px;
			margin-bottom: 10px;
			.title{
				font-weight: 900;
				padding: 10px 0;
				color: #666;
			}
			.box2-content{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 5px;
				view{
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					align-items: center;
				}
			}
		}
		.box3{
			background-color: #fff;
			box-shadow: 0 5px 2px 0px #eee;
			border-radius: 2px;
			padding: 10px;
			view{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 10px 0;
			}
		}
	}
}
</style>